 # -*- coding:utf-8 -*-
#! python3

from facecat import *

#更新悬浮状态
#views:视图集合
def updateView(views):
	updateViewDefault(views)

#绘制视图
#view:视图
#paint:绘图对象
#clipRect:区域
def onPaint(view, paint, clipRect):
	onPaintDefault(view, paint, clipRect) 

#绘制视图边线
#view:视图
#paint:绘图对象
#clipRect:区域
def onPaintBorder(view, paint, clipRect):
	onPaintBorderDefault(view, paint, clipRect)

#视图的鼠标移动方法
#view 视图
#mp 坐标
#buttons 按钮 0未按下 1左键 2右键
#clicks 点击次数
#delta 滚轮值
def onMouseMove(view, mp, buttons, clicks, delta):
	onMouseMoveDefault(view, mp, buttons, clicks, delta)
		
#视图的鼠标按下方法
#view 视图
#mp 坐标
#buttons 按钮 0未按下 1左键 2右键
#clicks 点击次数
#delta 滚轮值
def onMouseDown(view, mp, buttons, clicks, delta):
	onMouseDownDefault(view, mp, buttons, clicks, delta)

#视图的鼠标抬起方法
#view 视图
#mp 坐标
#buttons 按钮 0未按下 1左键 2右键
#clicks 点击次数
#delta 滚轮值
def onMouseUp(view, mp, buttons, clicks, delta):
	onMouseUpDefault(view, mp, buttons, clicks, delta)

#视图的鼠标点击方法
#view 视图
#firstTouch:是否第一次触摸 
#firstPoint:第一次触摸的坐标 
#secondTouch:是否第二次触摸 
#secondPoint:第二次触摸的坐标
#clicks 点击次数
def onClick(view, firstTouch, firstPoint, secondTouch, secondPoint, clicks):
	onClickDefault(view, firstTouch, firstPoint, secondTouch, secondPoint, clicks)

#视图的鼠标滚动方法
#view 视图
#mp 坐标
#buttons 按钮 0未按下 1左键 2右键
#clicks 点击次数
#delta 滚轮值
def onMouseWheel(view, mp, buttons, clicks, delta):
	onMouseWheelDefault(view, mp, buttons, clicks, delta)

appPaint = FCPaint() #创建绘图对象
appPaint.defaultUIStyle = "dark"
#初始化各种回调事件
appPaint.onPaint = onPaint 
appPaint.onPaintBorder = onPaintBorder
appPaint.onMouseDown = onMouseDown 
appPaint.onMouseMove = onMouseMove 
appPaint.onMouseUp = onMouseUp
appPaint.onMouseWheel = onMouseWheel
appPaint.onClick = onClick
appPaint.onUpdateView = updateView

#消息循环
def WndProc(hwnd,msg,wParam,lParam):
	return WndProcDefault(appPaint,hwnd,msg,wParam,lParam)

#创建窗体
createMainWindow(appPaint, "facecat-py", WndProc)
#创建图层
div = FCDiv()
div.paint = appPaint
if div.paint.defaultUIStyle == "dark":
	div.backColor = "rgb(0,0,0)"
	div.borderColor = "rgb(100,100,100)"
	div.textColor = "rgb(255,255,255)"
	div.scrollBarColor = "rgb(100,100,100)"
elif div.paint.defaultUIStyle == "light":
	div.backColor = "rgb(255,255,255)"
	div.borderColor = "rgb(150,150,150)"
	div.textColor = "rgb(0,0,0)"
	div.scrollBarColor = "rgb(200,200,200)"
#显示横向滚动条
div.showHScrollBar = True
#显示纵向滚动条
div.showVScrollBar = True
#填充满整个布局 
div.dock = "fill"
#添加到视图
addView(div, appPaint)
#添加子视图
for i in range(0,10):
	subDiv = FCDiv()
	#设置位置
	subDiv.location = FCPoint(i * 200, i * 200)
	#设置大小
	subDiv.size = FCSize(200, 200)
	#显示横向滚动条
	subDiv.showHScrollBar = True
	#显示纵向滚动条
	subDiv.showVScrollBar = True
	#添加到父视图
	addViewToParent(subDiv, div)
	#根据主题配色
	if div.paint.defaultUIStyle == "dark":
		subDiv.backColor = "rgb(0,0,0)"
		subDiv.borderColor = "rgb(100,100,100)"
		subDiv.textColor = "rgb(255,255,255)"
		subDiv.scrollBarColor = "rgb(100,100,100)"
	elif div.paint.defaultUIStyle == "light":
		subDiv.backColor = "rgb(255,255,255)"
		subDiv.borderColor = "rgb(150,150,150)"
		subDiv.textColor = "rgb(0,0,0)"
		subDiv.scrollBarColor = "rgb(200,200,200)"
	#添加孙视图
	for j in range(0,10):
		sunDiv = FCButton()
		#设置位置
		sunDiv.location = FCPoint(j * 20, j * 40)
		#设置大小
		sunDiv.size = FCSize(100, 20)
		#设置显示的文字
		sunDiv.text = "按钮" + str(i) + "," + str(j)
		#添加到父视图
		addViewToParent(sunDiv,subDiv)
		#允许拖动
		sunDiv.allowDrag = True;
		#根据主题配色
		if div.paint.defaultUIStyle == "dark":
			sunDiv.backColor = "rgb(0,0,0)"
			sunDiv.borderColor = "rgb(100,100,100)"
			sunDiv.textColor = "rgb(255,255,255)"
		elif div.paint.defaultUIStyle == "light":
			sunDiv.backColor = "rgb(255,255,255)"
			sunDiv.borderColor = "rgb(150,150,150)"
			sunDiv.textColor = "rgb(0,0,0)"

floatDiv = FCView()
addView(floatDiv, appPaint)
floatDiv.location = FCPoint(200, 200)
floatDiv.size = FCSize(200, 200)
floatDiv.backColor = "rgb(255,0,0)"
floatDiv.autoHide = True
floatDiv.viewName = "aaa"

#获取窗体大小
rect = win32gui.GetClientRect(appPaint.hWnd)
#更新布局
appPaint.size = FCSize(rect[2] - rect[0], rect[3] - rect[1])
updateView(appPaint.views)
showWindow(appPaint)